#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>

using std::cin;
using std::cout;
using std::vector;

template<typename Iter, typename Comp>
Iter Partition(Iter begin, Iter end, typename std::iterator_traits<Iter>::value_type elem, Comp cmp) {
	if (begin == end) {
		return end;
	}
	--end;
	while (begin != end) {
		while (begin != end && cmp(*begin, elem)) {
			++begin;
		}
		while (begin != end && !cmp(*end, elem)) {
			--end;
		}
		if (begin != end) {
			std::swap(*begin, *end);
		}
	}
	if (cmp(*end, elem)) {
		++end;
	}
	return end;
}

template<typename T>
void Input(std::istream &input, vector<T> &sequence, T &elem) {
	size_t size;
	input >> size;
	sequence.resize(size);
	for (size_t index = 0; index < size; ++index) {
		input >> sequence[index];
	}
	input >> elem;
}

template<typename T>
void Output(std::ostream &output, T first, T second) {
	output << first << "\n" << second;
}

int main() {
	vector<int> sequence;
	int elem;
	Input(cin, sequence, elem);
	auto separate = Partition(sequence.begin(), sequence.end(), elem, std::less<int>());
	Output(cout, separate - sequence.begin(), sequence.end() - separate);
}
